<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative; height:24px;">
  	<span class="red">温馨提示：</span>为了避免不小心操作误删导致其他功能不能正常使用，请勿乱删除任何菜单信息。
      <div class="content-menu" style="position: absolute; right: 30px;top: 5px;">
        <a href="javascript:openWinBox('__URL__/add','添加菜单')" class="add fb"><em>添加菜单</em></a>
      </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="__URL__/updateSort" method="post">
  <div class="table-list">
  <table width="100%" cellspacing="0" >
    <thead>
      <tr>
        <th width="38">排序</th>
        <th align='center' width='50'>菜单级别</th>
        <th align='left' width="220">菜单名称<span style="cursor:pointer; margin-left:10px;" onclick="showMenu()" id="showMenu">(展开)</span></th>
        <th align='left'>菜单标识</th>
        <th align='left'>所属模型</th>
        <th align='left'>所属控制器</th>
        <th align='left' >参数</th>
        <th align='center'>分组</th>
        <th align='center' width="60">状态</th>
        <th align='center' width="80"></th>
        <th >管理操作</th>
      </tr>
    </thead>
    <tbody>
      <volist name="list" id="vo">
        <tr class="topList level-1 list-{$vo.id}">
          <td align='center'><input name='sortArr[]' type='text' size='3' value='{$vo.sort}' class='input-text-c'><input name="idArr[]" type="hidden" value="{$vo.id}"></td>
          <td align='center'><font color="red">{$vo.levelName}</font></td>
          <td >{$vo.fullname}</td>
          <td align='left'>{$vo.name}</td>
          <td align='left'>{$vo.c}</td>
          <td align='left'>{$vo.a}</td>
          <td align='left'>{$vo.parameter}</td>
          <td align='center'>{$vo.group}</td>
          <td align='center' style="cursor:pointer;" class="status" name="{$vo.id}">{$vo.status|statusArr}</td>
          <td ></td>
          <td align='center'>
            【<a href="javascript:openWinBox('__URL__/add/id/{$vo.id}','{$vo.name}')">修改</a>】
            【<a href="#" onclick="del({$vo.id});" class="del_button">删除</a>】
          </td>
        </tr>

      </volist>
    </tbody>
  </table>
  <div class="btn">
  <div id="pages">{$page}</div>
  <input name="submit" type="submit" class="button" value="更新排序">
  &nbsp;
  </div>
  </div>
  </div>

</form>
</body>
</html>
<script language="JavaScript">
$(document).ready(function(e) {
    $(".status").each(function(i, val) {
        var text = $(this).html();
        if (text == '已启用') {
            $(this).addClass('green');
        } else {
            $(this).attr('red');
        }
    });

    $(function() {
        $('#myform').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm() {
            return true;
        }

        function complete(data) {
            art.dialog({
                id: 'TNCICC',
                content: data.info,
                time: 2,
                icon: 'succeed'
            });
            closeWin(1500);
        }
    })

    $(".status").click(function() {
        var text = $(this).html();
        var id = $(this).attr('name');

        if (text == '已启用') {
            $(this).html('已禁用');
            $(this).addClass('red');
            $(this).removeClass('green');
            var status = 0;
        } else {
            $(this).html('已启用');
            $(this).addClass('green');
            $(this).removeClass('red');
            var status = 1;
        }
        $.get("__CONTROLLER__/changeStatus/id/" + id + "/status/" + status, function(data) {})
    });

});

function toggleList(id) {
    $(".list-" + id).toggle()
}

function showMenu() {
    $(".level-2").toggle()
    $(".level-3").toggle()
    var status = $("#showMenu").text();
    if (status == '(伸缩)') {
        $("#showMenu").text('(展开)');
    } else {
        $("#showMenu").html('(伸缩)');
    }
}

function del(id) {
    jQuery.get('__CONTROLLER__/del', encodeURI('id=' + id), success, 'json');

    function success(data) {
        $(".list-" + id).remove();
    }
}
</script>